home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10861 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: in2.uu.net!interaccess!usenet
  2. From: brianmcg@interaccess.com (Brian V. McGroarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: pointer-to-pointer usage
  5. Date: 20 Mar 1996 14:18:46 GMT
  6. Organization: Internet Squire
  7. Message-ID: <4ip446$g6h@nntp.interaccess.com>
  8. References: <4inbmp$506@ra.nrl.navy.mil>
  9. Reply-To: brianmcg@interaccess.com
  10. NNTP-Posting-Host: d41-isdn.nhe.interaccess.com
  11. X-Newsreader: Internet Squire 1.20
  12.  
  13. The function "int change_ptr( tempType **temp )" expects to see a pointer
  14. to a pointer to a tempType.  In the lines which are generating errors, you
  15. are only passing a pointer to tempType.
  16.  
  17.  
  18. Here is what each does:
  19.  
  20. >change_ptr(temp1);
  21.  
  22. This is simply a copy of temp1, which is a pointer to tempType.  You would
  23. need to take its address, for example: 
  24.  
  25. change_ptr( &temp1 );
  26.  
  27.  
  28. >change_ptr(&(*temp1));
  29. >change_ptr(&*temp1);
  30.  
  31. In both of the above, you are using * to resolve temp1 to the actual
  32. tempType before taking the address.  
  33.  
  34.  
  35.  
  36. John Peng-yung Cheng wrote:
  37. >Greetings,
  38.  
  39. >    Could someone explain the following warnings that I get when
  40. >I compile with GNU compiler?  Please ignore the -D switches in the
  41. >compiler statement; I am developing for vxWorks, but the OS should not
  42. >make a difference.  Obviously, the functions do not do anything useful,
  43. >but are just an extraction of my actual code.
  44.  
  45. [...]
  46.  
  47. >In particular, the first four function calls to change_ptr() are 
  48. >equivalent, but only the last one does not generate a warning.  Also,
  49. >the declaration and usage of change_ptr_2 does not generate any warnings.
  50.  
  51. [...]
  52.  
  53. >int change_ptr(tempType **temp)
  54. [...]
  55.  
  56. >tempType        *temp1;
  57. >tempPtr         temp2;
  58. >
  59. >change_ptr(temp1);
  60. >change_ptr(&(*temp1));
  61. >change_ptr(&*temp1);
  62. >change_ptr((tempType **)temp1);
  63. >change_ptr_2(&temp2);
  64.  
  65.  
  66.  
  67. ---
  68. Brian Valters McGroarty -- brianmcg@bix.com
  69. phone/fax (847) 439-7714
  70.  
  71.  
  72.  
  73.  
  74.  
  75.